<?php
namespace app\common\validate;
use think\Validate;

/**
 * 管理员验证器
 * @author Yel 
 * @copyright  yel  2019/7/1
 */

class AdminUsers extends Validate{

	//验证规则
	protected $rule = [
       'account'  	=>  'require|max:25|unique:admin_users',
       'email' 		=>  'require|email|unique:admin_users|regex:[_a-z0-9-]*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})',
       'password'	=>  'require|confirm:repassword',
       'phone' 		=>  'require|regex:1[345789]\d{9}|unique:admin_users',
       'admin_user_group_id' =>  'require|number'
    ];

    //验证错误的输出
    protected $message = [
       'account.require' => '账号是必须',
       'account.max'     => '名称最多不能超过25个字符',
       'account.unique'  => '该账号已经被使用',

       'email.require'  => '账号是必须',
       'email.regex'     => '邮箱格式错误',
       'email.unique'   => '该邮箱已经被使用',

       'password.require'  => '密码是必须',
       'password.confirm'  => '两次密码输入不一样',

       'phone.require'  => '电话号码是必须',
       'phone.regex'    => '电话号码格式错误',
       'phone.unique'   => '该电话号码已经被使用',

       'admin_user_group_id.require'  => '角色是必须',
       'admin_user_group_id.number'   => '参数错误',
    ];
    //场景
    protected $scene = [
        'add'   =>  ['account','email','password','phone','admin_user_group_id'],
    ]; 




}
